package com.blog.web.controller;

import com.blog.common.core.domain.R;
import com.blog.common.core.web.domain.AjaxResult;
import com.blog.common.domain.dto.FriendLinkDto;
import com.blog.common.domain.vo.FriendLinkVo;
import com.blog.web.service.FriendLinkService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 友链控制器
 * </p>
 *
 * @author Valerie
 * @date 2023/3/1
 **/
@Api(tags = "友链模块")
@RestController
public class FriendLinkController {

    @Resource
    private FriendLinkService friendLinkService;

    /**
     * 查看友链列表
     *
     * @return {@link R<List<FriendLinkVo>>} 友链列表
     */
    @ApiOperation(value = "查看友链列表")
    @GetMapping("/links")
    public R<List<FriendLinkVo>> listFriendLinks() {
        return R.ok(friendLinkService.listFriendLinks());
    }

    /**
     * 查看友链列表
     *
     * @return {@link R<Void>} 添加友链
     */
    @ApiOperation(value = "添加友链")
    @PostMapping("/saveLink")
    public R<Void> saveFriendLink(@RequestBody FriendLinkDto friendLinkDto) {
        friendLinkService.saveFriendLink(friendLinkDto);
        return R.ok();
    }

}
